namespace PickGold.Charting
{
    using System;
    using System.Collections;
    using System.ComponentModel;

    internal class SeriesDataSourceMemberConverter : StringConverter
    {
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList values = new ArrayList();
            Chart chartFromContext = ConverterHelper.GetChartFromContext(context);
            object dataSource = null;
            if (chartFromContext != null)
            {
                if ((chartFromContext != null) && ChartImage.IsValidDataSource(chartFromContext.DataSource))
                {
                    dataSource = chartFromContext.DataSource;
                }
                bool usedForYValue = false;
                if ((context.PropertyDescriptor != null) && (context.PropertyDescriptor.Name == "YValueMembers"))
                {
                    usedForYValue = true;
                }
                foreach (string str in ChartImage.GetDataSourceMemberNames(dataSource, usedForYValue))
                {
                    values.Add(str);
                }
                values.Add("(none)");
            }
            return new TypeConverter.StandardValuesCollection(values);
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return false;
        }

        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }
    }
}

